package ejb.casacentral.jms;

import javax.ejb.ActivationConfigProperty;
import javax.ejb.EJB;
import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

import ejb.casacentral.service.FachadaSession;

/**
 * Message-Driven Bean implementation class for: Reciver
 *
 */
@MessageDriven(activationConfig = {
		@ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
		@ActivationConfigProperty(propertyName="destination", propertyValue="queue/ordenCompraAcepQueue")
	})
public class OrdenesCompraJMS implements MessageListener {

	
	@EJB
	private FachadaSession fachadaSession;
	
	

    /**
     * Default constructor. 
     */
    public OrdenesCompraJMS() {
        // TODO Auto-generated constructor stub
    }
	
	/**
     * @see MessageListener#onMessage(Message)
     */
    public void onMessage(Message message) {
        if(message instanceof TextMessage){
        	TextMessage texto = (TextMessage)message;
        	
        	try {
				
        		fachadaSession.recibirOrdenAceptada(texto.getText());
        		
			} catch (JMSException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        }
        
    }

}
